#ifndef XMLHANDLER_H
#define XMLHANDLER_H

#include "IChessView.h"
#include <vector>
#include <string>
#include "board.h"
#include "pugixml.hpp"

class XMLHandler
{
public:
    IChessView * myView;
    Board * myBoard;
    std::vector <std::string> board;
    std::vector <std::string> history;

    std::string currentGameXML;
    std::string XMLGameToLoad;


    XMLHandler();
    ~XMLHandler();
    void setView(IChessView * view , Board * board);
    void loadGame(std::string filename);
    void saveGame(std::string filename);
    void saveGameAs(std::string filename);

    void UpdateCurrentXML();
    void addBoardToCurrentXML();


    void addPieceType(ChessPiece *p , std::string & piece);
    void addPieceColor(ChessPiece *p , std::string & piece);
    void addPieceRow(ChessPiece *p, std::string &piece);
    void addPieceCol(ChessPiece *p, std::string &piece);
    void addHistoryToCurrentXML();
    std::string addMoveToHistory(Move m);
    std::string addMorePieceType(ImageName n);
    Move addPieces(pugi::xml_node start, pugi::xml_node end, pugi::xml_node kill);
    void addToPiecesOnBoard(std::string type, std::string cor, int row, int col);
};




#endif // XMLHANDLER_H
